package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MerchantStore;
import com.rockcent.mall.lib.domain.enumclass.MerchantStoreStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by oyhk on 14-6-22.
 *
 */
@Repository
public interface MerchantStoreRepository extends JpaRepository<MerchantStore, Long>, JpaSpecificationExecutor, MerchantStoreRepositoryCustom {




    long countByMerchantIdAndStatus(Long merchantId, MerchantStoreStatus status);

    List<MerchantStore> findByMerchantIdAndStatusAndMallId(Long merchantId,MerchantStoreStatus status,Long mallId);

    List<MerchantStore> findByStatusAndIdInAndMallId(MerchantStoreStatus status,List<Long> ids,Long mallId);

    MerchantStore findByIdAndMerchantIdAndMallIdAndIsDelete(Long storeId, Long merchantId, Long mallId, Whether no);

    List<MerchantStore> findByStatusAndExchangeAndIdInAndMallId(MerchantStoreStatus enable, Whether yes, List<Long> storesIdList, Long mallId);

    List<MerchantStore> findByMerchantIdAndStatusAndExchangeAndMallId(Long merchantId, MerchantStoreStatus enable, Whether yes, Long mallId);

    MerchantStore findByIdAndStatusAndIsDelete(Long storeId, MerchantStoreStatus enable, Whether no);

    List<MerchantStore> findByMerchantIdAndExchangeAndStatusAndIsDelete(Long merchantId, Whether exchange, MerchantStoreStatus status, Whether isDelete);

    List<MerchantStore> findByStatusAndExchangeAndIdInAndMerchantId(MerchantStoreStatus enable, Whether yes, List<Long> storesIdList, Long mallId);

    List<MerchantStore> findByStatusAndExchangeAndIdIn(MerchantStoreStatus enable, Whether yes, List<Long> storeIdList);
}